﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data.Odbc;

namespace Migrator
{
    class Program
    {
        public static void usageMigrator()
        {
            Console.Write(">> Migrator.exe [-o|-i] [mssql|mysql|oracle|postgres] [output_file]\n");
            Console.Write(">> -o : migrate from [db]\n");
            Console.Write(">> -i : migrate to   [db]\n");
            Console.ReadKey();
        }

        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                usageMigrator();
            }

            try
            {
                using (StreamReader sql_file = File.OpenText("../sql/" + args[1] + "/reverse.sql"))
                {
                    string read = null;
                    String SQL_comands = null;
                    while ((read = sql_file.ReadLine()) != null)
                    {
                        SQL_comands += read;
                    }
                    sql_file.Close();
                    sql_connect(args[1], "base", "12345");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadKey();
            }
        }

        private static void sql_connect(String DBMS, String DBMS_Username, String DBMS_Password)
        {

            OdbcConnection conn = new OdbcConnection();
            conn.ConnectionString =
                "Driver={Oracle ODBC Driver};" +
                "ConnectString=OracleServer.world;" +
                "Uid=base;" +
                "Pwd=12345;";
            conn.Open();
//             OleDbConnection conn = new OleDbConnection();
//             conn.ConnectionString =
//                           "provider=MSDAORA;" +
//                           "Data Source=(local);" +
//                           "User id=base;" +
//                           "Password=12345;";
//             conn.Open();

//             String StringConnect = null;
//             if (DBMS.CompareTo("oracle") == 0)
//             {
//                 StringConnect = "Data Source=(local);User Id=" + DBMS_Username + ";Password=" + DBMS_Password + ";";
//             }
//             SqlConnection sqlconnection = new SqlConnection(StringConnect);
// 
//             sqlconnection.Open();
// 
//             Console.WriteLine("State: {0}", sqlconnection.State);
//             Console.WriteLine("ConnectionString: {0}",
//                 sqlconnection.ConnectionString);
        }
    }
}
